package com.econ.powercloud.ems.common.enums;

/**
 * @Author : zjf
 * @Description : 簇的故障/告警状态
 * @Date : 2022/4/11 8:27
 * @Modified by : zjf
 */
public enum AlarmOrFaultState implements EnumMethod {
    FAULT(2,"故障"),
    ALARM(1,"告警"),
    NORMAL(0,"正常");
    private Integer code;
    private String desc;

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }


    AlarmOrFaultState(int code, String desc){
        this.code=code;
        this.desc=desc;
    }

    public static AlarmOrFaultState fromCode(int code){
        for(AlarmOrFaultState type: AlarmOrFaultState.values()){
            if(type.getCode() == code){
                return type;
            }
        }
        return null;
    }

    public static String getDescFromCode(int code){
        for(AlarmOrFaultState type: AlarmOrFaultState.values()){
            if(type.getCode() == code){
                return type.getDesc();
            }
        }
        return null;
    }
}
